from django.db import models
from user.models import User
# Create your models here.


class Cate(models.Model):
    name = models.CharField(max_length=255, verbose_name='分类名称')

    class Meta:
        db_table = 'cate'


class HomePage(models.Model):
    title = models.CharField(max_length=255, verbose_name='标题')
    image = models.CharField(max_length=255, verbose_name='图片', default='', blank=True, null=True)
    like = models.CharField(max_length=100, verbose_name='点赞数', default=0)
    publish = models.CharField(max_length=255, verbose_name='发布者')
    publish_img = models.CharField(max_length=255, verbose_name='发布者头像')
    is_show = models.BooleanField(default=True, verbose_name='是否展示')
    is_recommend = models.BooleanField(default=True, verbose_name='是否推荐')
    cate = models.ForeignKey(Cate, on_delete=models.CASCADE, verbose_name='分类id', blank=True, null=True)
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='用户id', blank=True, null=True)

    def __str__(self):
        return self.title

    class Meta:
        db_table = 'homepage'


class HomePage1(models.Model):
    title = models.CharField(max_length=255, verbose_name='标题')
    image = models.CharField(max_length=255, verbose_name='图片', default='', blank=True, null=True)
    like = models.CharField(max_length=100, verbose_name='点赞数', default=0)
    publish = models.CharField(max_length=255, verbose_name='发布者')
    publish_img = models.CharField(max_length=255, verbose_name='发布者头像')
    is_show = models.BooleanField(default=True, verbose_name='是否展示')
    is_recommend = models.BooleanField(default=True, verbose_name='是否推荐')
    cate = models.ForeignKey(Cate, on_delete=models.CASCADE, verbose_name='分类id', blank=True, null=True)
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='用户id', blank=True, null=True)

    def __str__(self):
        return self.title

    class Meta:
        db_table = 'homepage1'


class HomePage2(models.Model):
    title = models.CharField(max_length=255, verbose_name='标题')
    image = models.CharField(max_length=255, verbose_name='图片', default='', blank=True, null=True)
    like = models.CharField(max_length=100, verbose_name='点赞数', default=0)
    publish = models.CharField(max_length=255, verbose_name='发布者')
    publish_img = models.CharField(max_length=255, verbose_name='发布者头像')
    is_show = models.BooleanField(default=True, verbose_name='是否展示')
    is_recommend = models.BooleanField(default=True, verbose_name='是否推荐')
    cate = models.ForeignKey(Cate, on_delete=models.CASCADE, verbose_name='分类id', blank=True, null=True)
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='用户id', blank=True, null=True)

    def __str__(self):
        return self.title

    class Meta:
        db_table = 'homepage2'


class BrowsingHistory(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='用户id', blank=True, null=True)
    homepage = models.ForeignKey(HomePage, on_delete=models.CASCADE, verbose_name='视频id')
    is_show = models.BooleanField(default=True, verbose_name='是否展示')

    class Meta:
        db_table = 'browsing'
